package org.onion.pattern.sample.order.listener;

import lombok.extern.slf4j.Slf4j;
import org.onion.pattern.event.domain.annotation.ConsumeLogger;
import org.onion.pattern.event.domain.annotation.ExactlyOnce;
import org.onion.pattern.event.domain.annotation.RetryRule;
import org.onion.pattern.event.spring.external.rocketmq.annotation.enums.ListenerMode;
import org.onion.pattern.event.spring.external.rocketmq.annotation.RocketmqEventListener;
import org.onion.pattern.event.spring.external.rocketmq.annotation.RocketConsumerGroup;
import org.onion.pattern.sample.order.doamin.pay.event.PayRefundEvent;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@RocketConsumerGroup(value = "TExternalEventListener", listenerMode = ListenerMode.Concurrently)
@ConsumeLogger
@ExactlyOnce
@RetryRule
public class TExternalEventListener {

    /**
     * 在提交之后做
     * //TODO rocketmq 元数据，作为参数加入  何挺强
     *
     * @param event
     */
    @RocketmqEventListener(PayRefundEvent.class)
    public void on(PayRefundEvent event) {
//        if(1==1){
//            throw new IllegalStateException("处理失败");
//        }

        log.info("PayRefundEvent ======= xx=======");
        //外部事件...

//        System.out.println("进入 PayEvent5 事件");
//
//        //同步处理 ，在提交之前执行，会回滚。 失败结果会返回到前端
//        Assert.notNull(null, "在提交之前执行，事务回滚");
    }


}
